/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package coms.interceptors;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 *
 * @author Atul
 */
public class LayoutInterceptor implements Interceptor {
    
    public LayoutInterceptor() {
    }
    
    public void destroy() {
        System.out.println("LayoutInterceptor: destroy");
    }
    
    public void init() {
        System.out.println("LayoutInterceptor: init");
    }
    
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        System.out.println("LayoutIterceptor - start");
        String result = actionInvocation.invoke();
    //    ResultConfig config = actionInvocation.getProxy().getConfig().getResults().get(result);
   //     String location = config.getParams().get("location");
    //    System.out.println("config - before" + config.getParams().get("location"));
       // config.getParams().put("location", "/layout.jsp");
    /*    System.out.println("ResultConfig:" + config.toString());
        System.out.println("config" + config.getParams().toString());
        System.out.println("config after" + config.getParams().get("location"));
        System.out.println("Result is:"+result);
        actionInvocation.getStack().set("RESULT_PAGE", location);
        System.out.println("LayoutIterceptor - end");*/
        return result;
    }
}
